package sparrowGui.skin
{
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.text.TextField;
	
	import sparrowGui.Component;
	import sparrowGui.ComponentDraw;
	import sparrowGui.SparrowGUI;
	import sparrowGui.item.Item;
	import sparrowGui.vars.ComponentVars;
	
	/**
	 * 窗拖动窗体的皮肤
	 * 里面有标题文本,关闭按钮,缩小按钮
	 * @author Administrator
	 * 
	 */	
	public class WindowSkin extends Sprite
	{
		public var titBar:Sprite;
		public var txt_title:TextField;
		public var btn_close:Sprite;
		public var btn_mini:Sprite;
		public var panel:Sprite;
		public var win_bg:Sprite;
		
		public function WindowSkin()
		{
			init();
		}
		
		protected function init():void
		{
			var padding:int = 2;
			
			var winVars:ComponentVars = SparrowGUI.getIns().window_bg;
			win_bg = new ComponentDraw(winVars);
			
			
			var titBarVar:ComponentVars	= SparrowGUI.getIns().window_titBar;
			titBarVar.width = winVars.width;
			titBar	= new ComponentDraw(titBarVar);
			
			txt_title = new TextField();
			txt_title.selectable = false;
			txt_title.y = winVars.paddingTop;
			txt_title.x = winVars.paddingLeft;
			
			var closeVar:ComponentVars = SparrowGUI.getIns().btn_base;
			btn_close = new Item(null,null,closeVar);
			var lineShap:Shape = new Shape();
			lineShap.graphics.lineStyle(1,0x666666);
			lineShap.graphics.moveTo(padding,padding);
			lineShap.graphics.lineTo((closeVar.width-padding),(closeVar.height-padding));
			lineShap.graphics.moveTo((closeVar.width-padding),padding);
			lineShap.graphics.lineTo(padding,(closeVar.height-padding));
			btn_close.addChild(lineShap);
			
//			btn_mini = new Item(null,(new MiniBtnSkin()),SparrowGUI.getInstance().btn_base);
			btn_mini = new MiniBtnSkin();
			
			panel = new Sprite();
			panel.y = titBarVar.height;
			
			win_bg.name		= "win_bg";
			titBar.name		= "titBar";
			btn_mini.name	= "btn_mini";
			btn_close.name	= "btn_close";
			txt_title.name	= "txt_title";
			panel.name		= "panel";
			
			addChild(win_bg);
			addChild(titBar);
			addChild(txt_title);
			addChild(btn_mini);
			addChild(btn_close);
			addChild(panel);
		}
		
		override public function set width(value:Number):void
		{
			win_bg.width = value;
		}
		
		override public function set height(value:Number):void
		{
			win_bg.height = value;
		}
		
//		override protected function draw():void
//		{
//			super.draw();
//			
//		}
	}
}